Viewport = function(){
	return{
		clock: function(){
			var task = {
				run: function(){
					Ext.fly("clock").update(Ext.Date.format(new Date(), "d/m/Y h:i:s A"));
				},
				interval: 1000
			};
			Ext.TaskManager.start(task);
		},
		initWindow: function(config){
			//this.clock();
			new Ext.Viewport({
				id: "viewport",
				layout: "border",
				minWidth: 1000,
				minHeight: 600,
				items: [
			        {
			        	xtype: "container",
			        	contentEl: "header",
						region: "north",
						height: 50,
						border: false,
						cls:'header'
			        },{
			        	region: "center",
			        	margins: "0 5 5 5 ",
			        	layout: {
							type: "vbox",
							align : "stretch",
							pack  : "start"
						},
						autoScroll: true,
						items: config.items
			        },
			        new Ext.tree.Panel({
			        	title: Asg.constants.APPLICATION_TITLE,
			        	region: "west",
			        	margins: "0 0 5 5",
			        	collapsible: true,
						rootVisible: false,
						autoScroll: true,
			        	width: 250,
			        	listeners: {
			        		itemclick: function(tree, record){
			        			if(record && record.get("leaf") === true && !Ext.isEmpty(record.get("itemUrl")))
			        				Asg.Window.openSelfWindow(record.get("itemUrl"), record.get("itemUrlParams"));
			        		}
			        	},
			        	store: {
			        		fields: [
		        		         {name: "text"}, 
		        		         {name: "leaf"}, 
		        		         {name: "itemUrl"},
		        		         {name: "itemUrlParams"}
	        		         ],
							root: {
								expanded: true,
								text:"",
								children: [
						           {
						        	   text: "SEGURIDAD",
						        	   expanded: true,
						        	   children: [
				        	              {
				        	            	  text: "USUARIOS / ACCESSOS", 
				        	            	  leaf: true,
				        	            	  itemUrl: "admin/usuarios/view",
				        	            	  itemUrlParams: {header: "USUARIOS / ACCESSOS"}
			        	            	  }
			        	               ]
					        	   },{
					        		   text: "CATALOGO",
					        		   expanded: true,
					        		   children: [
			        		              {
	        		            			  text: "SEGUROS",
	        		            			  expanded: true,
	        		            			  children: [
    		            			             {
    		            			            	 text: "ASEGURADORAS", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/aseguradoras/view",
    					        	            	 itemUrlParams: {header: "ASEGURADORAS"}
		            			            	 },{
    		            			            	 text: "ASESORES", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/asesores/view",
    					        	            	 itemUrlParams: {header: "ASESORES"}
		            			            	 },{
    		            			            	 text: "TIPOS DE SEGUROS", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "TIPOS DE SEGUROS",
	        		            	            		 ctgCatalogoPadre: "00019"
	        		            	            	 }
		            			            	 },{
    		            			            	 text: "PLANES DE SEGURO", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/planes/view",
    					        	            	 itemUrlParams: {header: "PLANES DE SEGURO"}
		            			            	 }
		            			              ]
	        		            		  },{
	        		            			  text: "DISTRIBUCION TERRITORIAL",
	        		            			  expanded: true,
	        		            			  children: [
    		            			             {
    		            			            	 text: "MUNICIPIOS", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/municipios/view",
    					        	            	 itemUrlParams: {header: "MUNICIPIOS"}
		            			            	 },{
    		            			            	 text: "COLONIAS/CIUDADES", 
    		            			            	 leaf: true,
    		            			            	 itemUrl: "admin/colonias/view",
    					        	            	 itemUrlParams: {header: "COLONIAS/CIUDADES"}
		            			            	 }
		            			              ]
	        		            		  },{
			        		            	  text: "GENERALES",
			        		            	  expanded: true,
			        		            	  children: [
	        		            	             {
	        		            	            	 text: "CLASIFICACION DE EMPRESAS", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "CLASIFICACION DE EMPRESAS",
	        		            	            		 ctgCatalogoPadre: "00012"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "ESTADO CIVIL", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "ESTADO CIVIL",
	        		            	            		 ctgCatalogoPadre: "00087"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "FORMA DE PAGO PARA ABONOS", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "FORMA DE PAGO PARA ABONOS",
	        		            	            		 ctgCatalogoPadre: "00040"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "FORMA DE PAGO", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "FORMA DE PAGO",
	        		            	            		 ctgCatalogoPadre: "00009"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "LUGARES DE ABONOS", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "LUGARES DE ABONO",
	        		            	            		 ctgCatalogoPadre: "00044"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "PROFESION", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "PROFESION",
	        		            	            		 ctgCatalogoPadre: "00088"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "TIPOS DE CLIENTES", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "TIPOS DE CLIENTES",
	        		            	            		 ctgCatalogoPadre: "00016"
	        		            	            	 }
        		            	            	 },{
	        		            	            	 text: "TIPOS DE CONTACTOS", 
	        		            	            	 leaf: true,
	        		            	            	 itemUrl: "admin/catalogos/view",
	        		            	            	 itemUrlParams: {
	        		            	            		 header: "TIPOS DE CONTACTOS PARA SEGUIMIENTOS",
	        		            	            		 ctgCatalogoPadre: "00047"
	        		            	            	 }
        		            	            	 }
        		            	              ]
	        		            		  }
		        		               ]
					        	   }
					            ]
							}
			        	}
			        })
		        ]
			});
		}
	};
}();